package com.gears_software.sxdc.dccx.data.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.gears_software.sxdc.dccx.ui.util.NetUtils;
import com.sdsmdg.tastytoast.TastyToast;

/**
 * Created by chezhenzhen on 2017/10/24.
 */

public class NetStateReceiver extends BroadcastReceiver {

    private final static String ANDROID_NET_CHANGE_ACTION = "android.net.conn.CONNECTIVITY_CHANGE";

    @Override
    public void onReceive(Context context, Intent intent) {

        if (intent.getAction().equalsIgnoreCase(ANDROID_NET_CHANGE_ACTION)) {
            if (NetUtils.isNetworkAvailable(context)) {
                //Wifi情况下
                if (NetUtils.isWifiConnected(context)) {
                }
                //数据流量的情况下
                else {
                }
            } else {
                TastyToast.makeText(context, "网络异常，请检查网络连接", TastyToast.LENGTH_SHORT, TastyToast.WARNING);
            }
        }
    }
}


